package com.example;

import com.example.bean.ConsumerCompent;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ConsumerMain {
    public static void main(String[] args) throws Exception {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(PropertiesConfig.class);
        ConsumerCompent bean = applicationContext.getBean(ConsumerCompent.class);
        ExecutorService executorService = Executors.newCachedThreadPool();
        System.in.read();
        while (true){
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    bean.methodA();
                }
            });
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    bean.methodB();
                }
            });
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    bean.methodC();
                }
            });
            Thread.sleep(60);
        }

    }

    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    @EnableDubbo
    @ComponentScan(basePackages = "com.example.bean")
    static class PropertiesConfig{

    }
}
